﻿

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>选择店铺</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
</head>
<body>

    <div class="layui-form" lay-filter="layuiadmin-form-useradmin" id="layuiadmin-form-useradmin" style="padding: 20px 0 0 0;">
      <div class="layui-card">
     
            <div class="layui-card-header">选择管辖店铺</div>
            <div class="layui-card-body">
                <div id="select_store"></div>
            </div>
        </div>
      
        <div class="layui-form-item layui-hide">
            <input id="uidsub" class="form-control" name="uid" type="hidden" value="">

            <input type="button" lay-submit lay-filter="LAY-user-front-submit" lay-demotransferactive="getData" id="LAY-user-front-submit" value="确认">
        </div>
    </div>
    <script src="../../../layuiadmin/js/jquery.min2.1.4.js"></script>
    <script src="../../../layuiadmin/layui/layui.js"></script>
    <script src="../../../layuiadmin/js/jshelp.js"></script>
    <script>
        var storeid = eval(parent.arr_id);
        layui.config({
            base: '../../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'transfer', 'layer', 'util'], function () {
            var $ = layui.$
                , transfer = layui.transfer
                , layer = layui.layer
                , util = layui.util;
            //加载选项下拉框
            $.ajax({
                type: "post",
                url: "ashx/list.ashx?type=getstoreinfo",
                dataType: "json",
                success: function (data) {
                    //加载全部店铺列表
                    var data1 = [];
                    for (var i = 0; i < data.data.length; i++) {
                        var add = {
                            "value": data.data[i].id,
                            "title": data.data[i].name
                        };
                        data1.push(add);
                    }
                    //加载已选择店铺
                    var data2 = [];
                    for (var j = 0; j < storeid.length; j++) {
                        data2.push(storeid[j]);
                    }
                    //显示搜索框
                    transfer.render({
                        elem: '#select_store'
                        , data: data1
                        , value: data2
                        , id: 'getstore' //定义唯一索引
                        , title: ['店铺列表', '已选店铺']//左右列表显示名称
                        , showSearch: true//可以搜索
                    })
                },
                error: function (data) {
                    layer.error(data);
                }
            });
            //点击确定获取右边列表数据返回给隐藏控件
            util.event('lay-demoTransferActive', {
                getData: function (othis) {
                    var getData = transfer.getData('getstore'); //获取右侧数据
                    $("#uidsub").val(JSON.stringify(getData));
                }
            });
        });
    </script>
</body>
</html>